package com.guiadigital;


import com.guiadigital.entidades.Lugar;

import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.view.Menu;
import android.view.View;
import android.widget.AdapterView;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;

public class TipoLugares extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tipo_lugares);
        
        GridView gridview = (GridView) findViewById(R.id.gridview);
        gridview.setAdapter(new ImageAdapter(this));
        
        
        gridview.setOnItemClickListener(new GridView.OnItemClickListener() 
        {
        	 public void onItemClick(AdapterView<?> parent, View v, int position, long id) {

        		 try {
        			 //String imageId = (String)parent.getAdapter().getItem(position).toString();
                     Intent intent = new Intent(getApplicationContext(), Principal.class);
                     
                     String tipo=getTipo(position);
                                          
                     
                     
                     
                     SharedPreferences prefs = getSharedPreferences(
             				getString(R.string.configuraciones_guia_digital),
             				Context.MODE_PRIVATE);
             		
             		if (prefs != null) {
             			SharedPreferences.Editor editor = prefs.edit();
             		

             			// Guarda el valor de la configuracion
             			editor.putString("tipo", tipo);
             			// Comitea los valores modificados
             			editor.commit();
             		}
                     
                     
                     
                     
                     
                     //intent.putExtra("com.ui.SampleActivity", imageId);
                     startActivity(intent);
					} catch (Exception e) {
						System.out.println(e.getMessage());
					}

            }				
		}
        );
        //      gridview.setOnItemClickListener(new OnItemClickListener() {
        //       public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
        //            Toast.makeText(HelloGridView.this, "" + position, Toast.LENGTH_SHORT).show();
        //          }
        //  });
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_tipo_lugares, menu);
        return true;        
    }
     
    public String getTipo(int position)
    {
    	if(position==0) return "bar"; //anda
    	//if(position==1) return "hairdressing";//no trae 
    	//if(position==2) return "cafeteria"; //no trae
    	//if(position==3) return "electronics store";//se cae
    	//if(position==4) return "gas station";//se cae
    	if(position==5) return "food";//anda
    	//if(position==) return
    	//if(position==7) return "aquarium";//no trae
    	//if(position==) return 
    	if(position==9) return "hospital";//anda
    	if(position==10) return "gym";//anda
    	//if(position==) return "library"
    	//if(position==) return "library"
    	if(position==13) return "library";//anda
    	//if(position==14) return "cinema";//no trae
    	//if(position==) return "library"
    	//if(position==17) return "taxi";
    	//if(position==17) return "taxi";//no trae
    	if(position==20) return "";
    	//estaria bueno agregar airport,bank,bakery,casino,school,stadium,zoo por los que no andan.
    	else return "";
    }
}








